package org.tang.springcloudvv.mapper;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.JdbcType;
import org.tang.springcloudvv.model.Log4jSlowSql;
import org.tang.springcloudvv.model.Log4jSlowSqlExample;

import java.io.Serializable;
import java.util.List;

public interface Log4jSlowSqlMapper extends Serializable {
    @SelectProvider(type=Log4jSlowSqlSqlProvider.class, method="countByExample")
    long countByExample(Log4jSlowSqlExample example);

    @DeleteProvider(type=Log4jSlowSqlSqlProvider.class, method="deleteByExample")
    int deleteByExample(Log4jSlowSqlExample example);

    @Delete({
        "delete from log4j_slow_sql",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into log4j_slow_sql (user_id, phone, ",
        "event_path, from_app, ",
        "create_time, usedtime, ",
        "`sqlid`, sql_content)",
        "values (#{userId,jdbcType=INTEGER}, #{phone,jdbcType=VARCHAR}, ",
        "#{eventPath,jdbcType=VARCHAR}, #{fromApp,jdbcType=VARCHAR}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{usedtime,jdbcType=INTEGER}, ",
        "#{sqlid,jdbcType=VARCHAR}, #{sqlContent,jdbcType=LONGVARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(Log4jSlowSql record);

    @InsertProvider(type=Log4jSlowSqlSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insertSelective(Log4jSlowSql record);

    @SelectProvider(type=Log4jSlowSqlSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.INTEGER),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="event_path", property="eventPath", jdbcType=JdbcType.VARCHAR),
        @Result(column="from_app", property="fromApp", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="usedtime", property="usedtime", jdbcType=JdbcType.INTEGER),
        @Result(column="sqlid", property="sqlid", jdbcType=JdbcType.VARCHAR),
        @Result(column="sql_content", property="sqlContent", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Log4jSlowSql> selectByExampleWithBLOBsWithRowbounds(Log4jSlowSqlExample example, RowBounds rowBounds);

    @SelectProvider(type=Log4jSlowSqlSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.INTEGER),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="event_path", property="eventPath", jdbcType=JdbcType.VARCHAR),
        @Result(column="from_app", property="fromApp", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="usedtime", property="usedtime", jdbcType=JdbcType.INTEGER),
        @Result(column="sqlid", property="sqlid", jdbcType=JdbcType.VARCHAR),
        @Result(column="sql_content", property="sqlContent", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Log4jSlowSql> selectByExampleWithBLOBs(Log4jSlowSqlExample example);

    @SelectProvider(type=Log4jSlowSqlSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.INTEGER),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="event_path", property="eventPath", jdbcType=JdbcType.VARCHAR),
        @Result(column="from_app", property="fromApp", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="usedtime", property="usedtime", jdbcType=JdbcType.INTEGER),
        @Result(column="sqlid", property="sqlid", jdbcType=JdbcType.VARCHAR)
    })
    List<Log4jSlowSql> selectByExampleWithRowbounds(Log4jSlowSqlExample example, RowBounds rowBounds);

    @SelectProvider(type=Log4jSlowSqlSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.INTEGER),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="event_path", property="eventPath", jdbcType=JdbcType.VARCHAR),
        @Result(column="from_app", property="fromApp", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="usedtime", property="usedtime", jdbcType=JdbcType.INTEGER),
        @Result(column="sqlid", property="sqlid", jdbcType=JdbcType.VARCHAR)
    })
    List<Log4jSlowSql> selectByExample(Log4jSlowSqlExample example);

    @Select({
        "select",
        "id, user_id, phone, event_path, from_app, create_time, usedtime, `sqlid`, sql_content",
        "from log4j_slow_sql",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.INTEGER),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="event_path", property="eventPath", jdbcType=JdbcType.VARCHAR),
        @Result(column="from_app", property="fromApp", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="usedtime", property="usedtime", jdbcType=JdbcType.INTEGER),
        @Result(column="sqlid", property="sqlid", jdbcType=JdbcType.VARCHAR),
        @Result(column="sql_content", property="sqlContent", jdbcType=JdbcType.LONGVARCHAR)
    })
    Log4jSlowSql selectByPrimaryKey(Integer id);

    @UpdateProvider(type=Log4jSlowSqlSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Log4jSlowSql record, @Param("example") Log4jSlowSqlExample example);

    @UpdateProvider(type=Log4jSlowSqlSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") Log4jSlowSql record, @Param("example") Log4jSlowSqlExample example);

    @UpdateProvider(type=Log4jSlowSqlSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Log4jSlowSql record, @Param("example") Log4jSlowSqlExample example);

    @UpdateProvider(type=Log4jSlowSqlSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Log4jSlowSql record);

    @Update({
        "update log4j_slow_sql",
        "set user_id = #{userId,jdbcType=INTEGER},",
          "phone = #{phone,jdbcType=VARCHAR},",
          "event_path = #{eventPath,jdbcType=VARCHAR},",
          "from_app = #{fromApp,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "usedtime = #{usedtime,jdbcType=INTEGER},",
          "`sqlid` = #{sqlid,jdbcType=VARCHAR},",
          "sql_content = #{sqlContent,jdbcType=LONGVARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(Log4jSlowSql record);

    @Update({
        "update log4j_slow_sql",
        "set user_id = #{userId,jdbcType=INTEGER},",
          "phone = #{phone,jdbcType=VARCHAR},",
          "event_path = #{eventPath,jdbcType=VARCHAR},",
          "from_app = #{fromApp,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "usedtime = #{usedtime,jdbcType=INTEGER},",
          "`sqlid` = #{sqlid,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Log4jSlowSql record);
}